﻿<template>
    <div v-cloak class="h100 hidden-x">
        <component is="style" />
        <hxt-refresh v-model="refresh.isLoading" :has-more="refresh.hasMore" v-on:loadList="loadList">
            <van-cell :title="item.title" is-link v-for="(item,index) in list" v-on:click="open(item)"></van-cell>
        </hxt-refresh>
        <hxt-popup v-model="show" round style="height:95%;" closeable getContainer="body">
            <template #title>
                {{title}}
            </template>
            <iframe :src="url" width="100%" height="100%"></iframe>
        </hxt-popup>
    </div>
</template>
<script>
    module = (function (hxt) {
        return {
            name: 'user',
            data: function () {
                return {
                    optor: hxt.store.optor,
                    currentUser: hxt.store.optor,
                    browser: hxt.wxBrowser(), // 1：手机微信；4：小程序
                    refresh: { hasMore: true, isLoading: false },
                    query: {
                        pageIndex: 0,
                        pageSize: 20,
                        rowCount: 0
                    },
                    list: [],
                    show: false,
                    title:'',
                    url:'https://www.example.com',
                };
            },
            computed: {

            },
            activated: function () {

            },
            watch: {

            },
            mounted: function () {
                var _this = this;
                _this.$parent.showHome = true;
                _this.loadList();
            },
            methods: {
                loadList: function (e) {
                    var _this = this;
                    var _this = this;
                    if (!e) {
                        _this.query.pageIndex = 1;
                    };
                    hxt.post({
                        url: hxt.config.link + 'pc/wangEditorList',
                        data: {
                            openId: _this.optor.openId,
                            pageIndex: _this.query.pageIndex,
                            pageSize: _this.query.pageSize
                        },
                        ok: function (res) {
                            if (res.code != 0) {
                                _this.refresh.hasMore = !!e;
                                hxt.alert(res.errmsg, '加载失败');
                                return;
                            }
                            var list = _this.query.pageIndex == 1 ? [] : _this.list;
                            _this.list = list.concat(res.data.list);
                            _this.query.pageIndex++;
                            _this.refresh.hasMore = res.data.pageIndex * res.data.pageSize < res.data.rowCount;
                        },
                        complete: function () {
                            _this.refresh.isLoading = false;
                        },
                        error: function (err) {
                            _this.refresh.hasMore = !!e;
                        }
                    });
                },
                open: function (g) {
                    var _this = this;
                    var url = hxt.config.link + 'pc/wangEditorShare?id=' + g.id;
                    _this.url = url;
                    _this.show = true;
                    _this.title = g.title;
                    //window.open(url);
                }
            },
            components: {

            }
        };
    })(window.$jscript.fn);
</script>
<style>
    iframe{
        border:none;
    }
</style>